﻿#pragma once
#include "../ImGui/imgui.h"
#include <d3d11.h>
#include <dxgi.h>
#include <random>
#include <vector>
#include <windows.h>

#pragma comment(lib, "d3d11.lib")
#pragma comment(lib, "dxgi.lib")

class AnimationSystem {
public:
	struct Particle {
		ImVec2 position;
		ImVec2 velocity;
		float size;
		float lifetime;
		float maxLifetime;
		ImVec4 color;
	};

	struct TrailPoint {
		ImVec2 position;
		ImVec4 color;
		float lifetime;
	};

	static bool Initialize();

	static void Shutdown();

	static bool Render();

	static void SetProgress(float progress);

	static float GetProgress();

private:
	static HWND hWnd;

	static ID3D11Device* pDevice;
	static ID3D11DeviceContext* pDeviceContext;
	static IDXGISwapChain* pSwapChain;
	static ID3D11RenderTargetView* mainRenderTargetView;

	static float progress;
	static float prevProgress;
	static float progressSmooth;

	static std::vector<Particle> particles;
	static std::vector<TrailPoint> trailPoints;
	static std::mt19937 rng;

	static bool CreateDeviceD3D(HWND hWnd);

	static void CleanupDeviceD3D();

	static void CreateRenderTarget();

	static void CleanupRenderTarget();

	static LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);

	static void UpdateProgressSmoothing(float deltaTime);

	static void UpdateParticles(float deltaTime);

	static void UpdateTrailPoints(float deltaTime);

	static void DrawTrailLines(ImDrawList* drawList, const ImVec2& windowPos);

	static const char* GetStatusText();

	static void SpawnRippleEffect(const ImVec2& center, float radius);

	static void SpawnParticles(int count);

	static void DrawScanLines(ImDrawList* drawList, const ImVec2& windowPos, int screenWidth, int screenHeight);

	static void DrawTechCirclePattern(ImDrawList* drawList, const ImVec2& center, float radius);

	static void DrawTechDecorations(ImDrawList* drawList, const ImVec2& windowPos, int screenWidth, int screenHeight);

	static void DrawCornerDecoration(ImDrawList* drawList, const ImVec2& cornerPos, const ImVec2& offset, float size, float opacity, bool left, bool top);

	static void SpawnProgressMilestoneEffect(const ImVec2& center);
};

extern const unsigned char* dllResource;